package TCP.ServerJointMultiClient02;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @Grup:PACKAGE_NAME
 * @Auther:cola
 * @Data:2021/4/1-2021-04-21:53
 * @version:1.0
 */
public class MutilClientDemo {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //创建一个Socket对象,指定要连接的服务器
        try {
            Socket socket = new Socket("localhost", 6869);
            //获取socket的输入输出流
            PrintStream ps = new PrintStream(new BufferedOutputStream(socket.getOutputStream()));
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            System.out.println("亲输入:");
            String info = input.nextLine();
            ps.println(info);
            ps.flush();
            //读取服务器端返回的数据
            info = br.readLine();
            System.out.println(info);
            ps.close();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
